package login.logic;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import login.bean.AssetBundleBean;
import login.dao.AssetBundleDao;

public class AssetBundleManager {

	private static Logger logger = LoggerFactory.getLogger(AssetBundleManager.class);

	private volatile List<AssetBundleBean> serverListCache = new ArrayList<AssetBundleBean>();

	static class SingletonHolder {
		static AssetBundleManager instance = new AssetBundleManager();
	}

	public static AssetBundleManager getInstance() {
		return SingletonHolder.instance;
	}

	public void reload() {
		logger.info("reload asset bundle list!");
		serverListCache = getAssetBundleFromDb();
	}

	public List<AssetBundleBean> getAssetBundleList() {
		return serverListCache;
	}

	public List<AssetBundleBean> getAssetBundleFromDb() {
		List<AssetBundleBean> retList = AssetBundleDao.getInstance().getServerList();
		return retList;
	}
}
